package Dao;

import static org.junit.Assert.*;

import java.util.ArrayList;
import java.util.List;

import org.junit.Before;
import org.junit.Test;

import Entity.Comment;

public class CommentInformationDaoTest {
	CommentInformationDao cd=new CommentInformationDao();
	List<Comment> clist=new ArrayList<Comment>();
	Comment comment=new Comment("201619462019061712520161946201", "2016194620190617125","20161946","非常棒的资源！！！","2019-07-06");

	@Before
	public void setUp() throws Exception {
	}

	@Test
	public void testAddComment() {
		assertEquals(1,cd.addComment(comment));
	}

	@Test
	public void testQueryCommentByResourceID() {
		clist=cd.queryCommentByResourceID("201619462019061712520161946201");
		for(int i=0;i<clist.size();i++) {
		assertEquals("201619462019061712520161946201",clist.get(i).commentID);
		assertEquals("2016194620190617125",clist.get(i).resourceID);
		assertEquals("20161946",clist.get(i).commentatorID);
		assertEquals("非常棒的资源！！！",clist.get(i).theContent);
		assertEquals("2019-07-06",clist.get(i).commentTime);
		}
	}

	@Test
	public void testQueryRecordCount() {
		assertEquals(2,cd.queryRecordCount());
	}

}

